home *** CD-ROM | disk | FTP | other *** search
Java Source | 2000-06-23 | 2.2 KB | 80 lines |
- /*
- * QuickTime for Java SDK Sample Code
-
- Usage subject to restrictions in SDK License Agreement
- * Copyright: © 1996-1999 Apple Computer, Inc.
-
- */
- package mixer.display;
-
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- import javax.swing.event.*;
- import quicktime.*;
- import quicktime.app.audio.*;
-
- import mixer.mc.*;
-
- /** This class represents a special kind of channel, which we call the master
- * control. Master controls can only have their volume and mute status controlled
- * by the mixer.
- */
- public class MasterDisplay extends ChannelDisplay {
-
- /** The contructor just needs to know which MixerComponents object it is creating
- * the display for.
- */
- public MasterDisplay (MixerComponents mixer) throws QTException {
- this (mixer, true, false, false, true);
- }
-
- protected MasterDisplay (MixerComponents mixer, boolean mute, boolean solo, boolean balance, boolean volume) throws QTException {
- super (mixer, mute, solo, balance, volume);
- }
-
- /* This is the ActionListener needed for mute buttons in master controls. */
- void addMuteAction (JCheckBox b) {
- try {
- b.setSelected (mixer.getMaster().isMuted());
- b.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- try {
- if (((JCheckBox) e.getSource()).isSelected())
- mixer.getMaster().setMuted(true);
- else
- mixer.getMaster().setMuted(false);
- }
- catch (QTException ex) {
- throw new QTRuntimeException (ex);
- }
- }
- });
- } catch (QTException e) {
- throw new QTRuntimeException (e);
- }
- }
-
- /* This is the ActionListener needed for volume controls. */
- void addVolumeAction (JSlider b) {
- try {
- b.setValue((int)(mixer.getMaster().getVolume() * 66.0F));
-
- b.addChangeListener(new ChangeListener() {
- public void stateChanged(ChangeEvent e) {
- try {
- Integer tmp = new Integer(((JSlider) e.getSource()).getValue());
- float v = tmp.floatValue();
- v = v / 66.0F;
- mixer.getMaster().setVolume(v);
- }
- catch (QTException ex) {
- throw new QTRuntimeException (ex);
- }
- }
- });
- } catch (QTException e) {
- throw new QTRuntimeException (e);
- }
- }
- }